﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>商家管理</title>
    <link href="~/plugins/layui/css/layui.css" rel="stylesheet" />
</head>
<body style="margin-left:10px;margin-top:10px;">
    <div id="ss" class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 30px;">
                <i class="layui-icon" style="font-size: 30px; color: #1E9FFF;">&#xe615;</i>
            </div>
            <div class="layui-input-inline layui-form layui-form-pane">
                <select name="flgid">
                    <option value="0" selected="">= 全部 =</option>
                    @foreach (var item in @ViewBag.cpfl)
                    {
                        if (@item.gid == @ViewBag.flgid)
                        {
                            <option value="@item.gid" selected="">@item.name</option>
                        }
                        else
                        {
                            <option value="@item.gid">@item.name</option>
                        }
                    }
                </select>
            </div>
            <div class="layui-input-inline" style="width: 150px;">
                <input type="text" placeholder="套餐名称" name="name" class="layui-input" value="@ViewBag.name" />
            </div>
            <div class="layui-input-inline layui-hide" style="width: 150px;">
                <input class="layui-input" placeholder="注册开始日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="stime" value="@ViewBag.stime">
            </div>
            <div class="layui-form-mid layui-hide">-</div>
            <div class="layui-input-inline layui-hide" style="width: 150px;">
                <input class="layui-input" placeholder="注册结束日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="etime" value="@ViewBag.etime">
            </div>
            <div class="layui-input-inline layui-hide" style="width: 150px;">
                <input class="layui-input" placeholder="收入开始日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="pstime" value="@ViewBag.pstime">
            </div>
            <div class="layui-form-mid layui-hide">-</div>
            <div class="layui-input-inline layui-hide" style="width: 150px;">
                <input class="layui-input" placeholder="收入结束日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="petime" value="@ViewBag.petime">
            </div>
            <div class="layui-input-inline">
                <a onclick="javascript: page(-1,-1);" class="layui-btn">给偶搜</a>
            </div>
        </div>
    </div>
    <div class="layui-form">
        <table class="layui-table">
            <thead>
                <tr>
                    <th>套餐名称</th>
                    <th>售价</th>
                    <th>天数</th>
                    <th>是否显示</th>
                    <th>购买记录</th>
                    <th>管理操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                <tr id="@item.gid">
                    <td>
                        @item.name
                    </td>
                    <td>@item.payrmb</td>
                    <td>@item.xfx</td>
                    <td>@(item.show == 1 ? "显示" : "不显示")</td>
                    <td>
                        <div class="layui-btn-group">
                            <button class="layui-btn layui-btn-mini @(LJSheng.Common.LCookie.Getljsheng("qx")=="管理员"?"":"layui-hide")" onclick="Showiframe('@item.name','/ljsheng/ddlist?buygid=@item.gid');">查看订单</button>
                        </div>
                    </td>
                    <td>
                        <div class="layui-btn-group @(LJSheng.Common.LCookie.Getljsheng("qx")=="管理员"?"":"layui-hide")">
                            <button class="layui-btn layui-btn-mini" onclick="Showiframe('@item.name','/ljsheng/cpau?gid=@item.gid&flgid=@item.flgid&lx=3');">编辑</button>
                            <button class="layui-btn layui-btn-mini layui-hide" onclick="Delete('@item.gid');">删除</button>
                        </div>
                    </td>
                </tr>
                }
            </tbody>
        </table>
    </div>
    <div id="zhekou" class="layui-hide">
        <table class="layui-table">
            <colgroup>
                <col width="80">
                <col width="200">
                <col>
            </colgroup>
            <tbody>
                <tr>
                    <td>折扣名称</td>
                    <td><input type="text" name="dname" placeholder="起一个折扣名称" autocomplete="off" class="layui-input"></td>
                </tr>
                <tr>
                    <td>明折</td>
                    <td><input type="text" name="dmingzhe" placeholder="比如打8.8折输入 0.88(不打折填 1)" autocomplete="off" class="layui-input" onkeyup="value=value.replace(/[^\d.]/g,'');"></td>
                </tr>
                <tr>
                    <td>暗折</td>
                    <td><input type="text" name="danzhe" placeholder="比如平台收1折输入 0.1(不收取填 0)" autocomplete="off" class="layui-input" onkeyup="value=value.replace(/[^\d.]/g,'');"></td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center;"><label>例子:明折是0.88 暗折是0.1 会员消费1000(支付880=平台收100+商家拿780)</label></td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center;"><button class="layui-btn" onclick="upzk();">增加折扣</button></td>
                </tr>
            </tbody>
        </table>
    </div>
    <label id="gid" class="layui-hide"></label>
    <div id="page"></div>
    共 @ViewBag.count 条  <em style="color:red;">当前查询条件商家营业额=@ViewBag.parame1</em> <a href="javascript: daochu();" class="layui-btn">导出当前查询的数据</a>
    <script src="~/js/jquery.js"></script>
    <script src="~/plugins/layui/layui.js"></script>
    <script src="~/js/ljsheng.js"></script>
    <script src="~/js/daochu.js"></script>
    <script>
        page(@ViewBag.pages,@ViewBag.pageindex);
        //删除数据
        function Delete(gid) {
            layer.confirm('你确定要执行此操作吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "/ljsheng/cpdelete",
                    data: "gid=" + gid,
                    type: "post",
                    cache: false,
                    timeout: 8000,
                    dataType: "json",
                    ContentType: "application/json; charset=utf-8",
                    error: function () { layer.msg("请求超时"); },
                    beforeSend: function () { },
                    success: function (data) {
                        if (data.result == 200) {
                            $("#" + gid).hide(5);
                            layer.msg(data.data, { icon: 1 });
                        }
                        else {
                            layer.msg(data.data);
                        }
                    },
                });
            });
        }
        //重设密码
        function shmima(gid) {
            layer.confirm('你确定要执行此操作吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "/ljsheng/shmima",
                    data: "gid=" + gid,
                    type: "post",
                    cache: false,
                    timeout: 8000,
                    dataType: "json",
                    ContentType: "application/json; charset=utf-8",
                    error: function () { layer.msg("请求超时"); },
                    beforeSend: function () { },
                    success: function (data) {
                        if (data.result == 200) {
                            layer.msg(data.data, { icon: 1 });
                        }
                        else {
                            layer.msg(data.data);
                        }
                    },
                });
            });
        }
        //增加折扣界面
        function zhekou(gid,name) {
            document.getElementById("gid").innerHTML = gid;
            layer.open({
                type: 1,
                title: name,
                skin: 'layui-layer-rim', //加上边框
                area: ['500px', '380px'], //宽高
                content: document.getElementById("zhekou").innerHTML
            });
        }
        function upzk() {
            if (document.getElementsByName("dname")[1].value.length > 0 && document.getElementsByName("dmingzhe")[1].value.length > 0 && document.getElementsByName("danzhe")[1].value.length > 0) {
                $.ajax({
                    url: "/ljsheng/zhekouau",
                    data: "shopgid=" + document.getElementById("gid").innerHTML + "&name=" + document.getElementsByName("dname")[1].value + "&mingzhe=" + document.getElementsByName("dmingzhe")[1].value + "&anzhe=" + document.getElementsByName("danzhe")[1].value + "&Cache=" + Math.random(),
                    type: "post",
                    cache: false,
                    timeout: 8000,
                    dataType: "json",
                    ContentType: "application/json; charset=utf-8",
                    error: function () { layer.msg("请求超时"); },
                    beforeSend: function () { },
                    success: function (data) {
                        layer.msg(data.data, { icon: 1 });
                    },
                });
            }
            else
            {
                layer.msg("所有数据必填!", { icon: 1 });
            }
        }
    </script>
</body>
</html>
